package com.quxian.chambercommerce.admin_action;

import java.util.List;

import com.quxian.chambercommerce.base.BaseAction;
import com.quxian.chambercommerce.bean.TypeGroupEntity;
import com.quxian.chambercommerce.bean.TypeItemEntity;
import com.quxian.chambercommerce.service.TypeManageService;

public class TypeManageAction extends BaseAction{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private TypeManageService typeManageService;

	private String name;
	private int group_id;
	
	private List<TypeGroupEntity> listType;
	public TypeManageService getTypeManageService() {
		return typeManageService;
	}

	public void setTypeManageService(TypeManageService typeManageService) {
		this.typeManageService = typeManageService;
	}
	
	public List<TypeGroupEntity> getListType() {
		return listType;
	}

	public void setListType(List<TypeGroupEntity> listType) {
		this.listType = listType;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getGroup_id() {
		return group_id;
	}

	public void setGroup_id(int groupId) {
		group_id = groupId;
	}

	public String getAllType(){
		try {
			listType = typeManageService.getAllType();
			return SUCCESS;
		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}
	}
	
	public String insterItem(){
		try {
			TypeItemEntity entity = new TypeItemEntity();
			entity.setGroup_id(group_id);
			System.out.println("=====name===="+name);
			entity.setName(name);
			typeManageService.insterItem(entity);
			return SUCCESS;
		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}
	}
	
}
